#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
using namespace std;
typedef long long LL;
typedef double db;
inline int read()
{
	int x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9') { if(ch=='-')f=-1; ch=getchar(); }
	while(ch>='0'&&ch<='9') { x=(x<<1)+(x<<3)+ch-'0'; ch=getchar(); }
	return x*f;
}
const int MAXN=1100;
int n,x[MAXN],y[MAXN],r[MAXN],pre[MAXN],l[MAXN],tot,S,T;
db ans,s;
int main()
{
#ifndef ONLINE_JUDGE
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	n=read();x[0]=read();y[0]=read();
	for(int i=1;i<=n;++i)
	{
		x[i]=read();y[i]=read();r[i]=read();
		if(!x[i]&&!y[i])S=i;
	}
	queue<int>q;
	q.push(S);
	while(true)
	{
		int u=q.front();q.pop();
		if(x[u]==x[0]&&y[u]==y[0])
		{
			T=u;
			break;
		}
		for(int i=1;i<=n;++i)
		{
			if(pre[i])continue;
			if(abs(x[u]-x[i])*abs(x[u]-x[i])+abs(y[u]-y[i])*abs(y[u]-y[i])==(r[u]+r[i])*(r[u]+r[i]))
			{
				q.push(i);
				pre[i]=u;
			}
		}
	}
	for(int i=T;i!=S;i=pre[i])
		l[++tot]=i;
	l[tot+1]=S;
	ans=s=10000;
	for(int i=tot;i;--i)
	{
		s=s*r[l[i+1]]/r[l[i]];
		ans+=s;
	}
	printf("%d\n",(int)ans);
	return 0;
}
